import '../../App';

import React, { lazy, Suspense } from 'react'
import { NavLink, Routes, Route, Navigate } from 'react-router-dom'
// import About from './About';
// import Home from './Home';
const About = lazy(() => import('./About'))
const Home = lazy(() => import('./Home'))

export default function Demo() {
  function computedClassName({ isActive }) {
    return isActive ? "list-group-item myActive" : "list-group-item"
  }
  return (
    <div>
      <div>
        <div className="row">
          <div className="col-xs-offset-2 col-xs-8">
            <div className="page-header">
              <h2>React Router Demo</h2>
            </div>
          </div>
        </div>
        <div className="row">
          <div className="col-xs-2 col-xs-offset-2">
            <div className="list-group">
              <NavLink className={computedClassName} to="/about">
                About
              </NavLink>
              <NavLink className={computedClassName} to="/home">
                Home
              </NavLink>
            </div>
          </div>
          <div className="col-xs-6">
            <div className="panel">
              <div className="panel-body">
                <Suspense fallback={<h1>Loading........</h1>}>
                  <Routes>
                    <Route path="/about" element={<About />} />
                    <Route path="/home" element={<Home />} />
                    <Route path="/" element={<Navigate to="/home" />} />
                  </Routes>
                </Suspense>
              </div>
            </div>
          </div>
        </div>
      </div>
    </div>
  )
}

